﻿@using Wicresoft.UnifyShow.Portal;
@{
    ViewBag.Title = "基础环境状态";
    Layout = "~/Views/Shared/_LayoutSummary.cshtml";
    var x = ViewBag.SiteID;
}
<div class="right_title2">
    <a href="@Url.Action("index", "Home")">首页</a> > 业务状态总览 > @ViewData["ServiceAlias"]>
    <span>基础环境状态</span></div>
<input type="hidden" value="@ViewData["ServiceName"]" id="serviceName"/>
<input type="hidden" value="@ViewData["ServiceAlias"]" id="serviceAlias"/>
<!--**************************************************************************************************************************************************-->
<div class="class">
    <div class="tab_area">
        <ul class="tab_head tabs">
            @*<img src="@Url.Action("BusinessAvaliability", "Widget", new RouteValueDictionary() { { "bid", 1 } })" alt="" />*@
            @foreach (var item in ViewBag.Sites)
            {
                if (item.ID == ViewBag.SiteID)
                { 
                <li data-local="@item.ID" data-select="true"><a href="#@item.Name">@item.Alias</a></li>
                }
                else
                { 
                <li data-local="@item.ID"><a href="#@item.Name">@item.Alias</a></li>
                }
            }
        </ul>
        <div class="tab_container" id="tab_container">
            <!--**************************************************************************************************************************************************-->
        </div>
        <div class="clear">
        </div>
    </div>
</div>
@section ScriptAndCss
{
    <script type="text/javascript">

        function preventIncident()
    {
         PreventAAction("incidentTable");
    }

        function colorfulTheAlert()
        {
           PreventAAction("gridAlertTable");
           $("tr", $("thead", "#gridAlertTable")).children().first().hide();
           $("tr", $("tbody", "#gridAlertTable")).each(function()
           {
                       var id=$(this).children().first().text();
                       if(id==2){
                       $(this).css("background-color", "red");
                       }
                       else if(id==1)
                       {
                        $(this).css("background-color", "yellow");
                       }
                       else
                       {
                        $(this).css("background-color", "green");
                       }
           });
        }

        function initTab()
        {
           $("input.showRelatedAlert").click(function()
            {
            loadAlertTable($(this).attr("data-deviceID"));
            loadIncidentTable($(this).attr("data-deviceID"));
            });
           $("a.showPerformanceHistory").click(function()
           {
             var url="@Url.Action("GenerateReportDeviceID", "Performance")";
             url+="?deviceID="+$(this).attr("data-deviceID");
             window.open(url);
           });
         }


        function setTabContainer(local)
        {
         var serviceName=$("#serviceName").val();
         var url="@Url.Action("ContentPartialView", "BESContentPartialView")";
         if(serviceName.length!=0)
         {
          url=url+"?siteID="+local+"&serviceName="+serviceName;
         
          $("#tab_container").load(encodeURI(url),function()
          {
          loadAlertTable();
          loadIncidentTable();
          initTab();
          });
         }
        }

        function loadAlertTable(deviceID)
        {
         var serviceID=$("#serviceID").val();
         var siteID=$("li.c","ul.tabs").attr("data-local");
         var url="@Url.Action("AlertPartialView", "BESAlertPartialView")";
         if(deviceID==undefined)
         {
          url=url+"?siteID="+siteID+"&serviceID="+serviceID;
         }
         else
         {
          url=url+"?siteID="+siteID+"&serviceID="+serviceID+"&deviceID="+deviceID;
         }
         $("#alertTable").load(url,function()
         {
                    colorfulTheAlert();
         });
        }

        function loadIncidentTable(deviceID)
        {
         var serviceID=$("#serviceID").val();
         var siteID=$("li.c","ul.tabs").attr("data-local");
         var url="@Url.Action("IncidentPartialView", "BESIncidentPartialView")";
         if(deviceID==undefined)
         {
          url=url+"?siteID="+siteID+"&serviceID="+serviceID;
         }
         else
         {
          url=url+"?siteID="+siteID+"&serviceID="+serviceID+"&deviceID="+deviceID;
         }
         $("#incidentTable").load(url,function()
         {
         preventIncident();
         });
        }

        $(document).ready(function () {
            //$("li", "ul.tabs").first().addClass("c ui-icons").show(); //Activate first tab 
            $("li","ul.tabs").click(function () {
                $("li","ul.tabs").removeClass("c ui-icons"); //Remove any "active" class 
                $(this).addClass("c ui-icons"); //Add "active" class to selected tab 
                setTabContainer($(this).attr("data-local"));
            });
            $("li[data-select='true']","ul.tabs").click();
        });
   
    </script>
}
@section  LeftMenu {
    <li><a href="@Url.Action("Index", "BusinessAvailable", new { businessSystemId = ViewData["ServiceID"] })">
        业务健康度总览</a></li>
    <li class="VNavLeaf ui-icons">基础环境状态</li>
    <li><a href="@Url.Action("Index", "ITBusinessStatistics", new { businessSystemId = ViewData["ServiceID"] })">
        IT服务统计</a> </li>
    <li><a href="@Url.Action("Index", "ServiceLevelAgreement", new { businessSystemId = ViewData["ServiceID"] })">
        服务水平统计</a></li>
}
